<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">
    <h:head >

    </h:head>
    <h:body onload="document.getElementById('form1:codigo').focus()">
        <ui:composition template="templateTeste.xhtml">
            <ui:define name="centro">
                <p:messages globalOnly="true" showDetail="true"/>

                <h:form id="form1">
                    <h:inputHidden value="#{manterClienteBean.cliente.codigo}"/>





                    <h:outputText value="#{mens.NOME}" />
                    <p:inputText id="nome" value="#{manterClienteBean.cliente.nome}" required="true" size="30" title="#{mens.MENSAGEMNOME}"/>
                    <p:message for="nome"/>
                    <br/>

                      <!--

                    <h:outputText value="#{mens.CPFCNPJ}"/>

                    <p:inputMask id="cpfCnpj"   mask="999.999.999-99" required="true" value="#{manterClienteBean.cliente.cpfcnpj}" size="30" />
                    <p:message for="cpfCnpj"/>
                    <br/>

                       !-->
                           <h:selectOneRadio id="cpfCnpj" value="#{manterClienteBean.cliente.cpfcnpj}"
                                         title="#{mens.MENSAGEMRADIO}">
                               <f:selectItem itemLabel="CNPJ" itemValue="#{true}"/>
                               <f:selectItem itemLabel="CPF"  itemValue="#{false}"/>
                               <p:ajax update="CNPJ, CPF" event="change" />
                           </h:selectOneRadio>

                           <h:outputText />

                           <h:outputLabel value="#{mens.CNPJ}"/>
                           <p:inputMask id="CNPJ"   size="20" mask="99.999.999/9999-99" 
                                        disabled="#{manterClienteBean.cliente.cpfcnpj ? false : true}"
                                        required="true"
                                        value="#{manterClienteBean.cliente.cpfcnpj}"
                                        title="#{mens.MENSAGEMCNPJ}">

                           </p:inputMask>

                           <p:message for="CNPJ" />

                           <h:outputLabel value="#{mens.CPF}" />
                           <p:inputMask  id="CPF"   size="20" mask="999.999.999-99"
                                         disabled="#{manterClienteBean.cliente.cpfcnpj ? true : false}"
                                         required="true"
                                         value="#{manterClienteBean.cliente.cpfcnpj}"
                                         title="#{mens.MENSAGEMCPF}">


                           </p:inputMask>
                           <p:message for="CPF" />
                          <br/>

                    
                        

                  



                    <h:outputText value="#{mens.TELEFONE}" />
                    <p:inputMask id="telefone" mask="(99)9999-9999"  value="#{manterClienteBean.cliente.telefone}" size="30" title="#{mens.MENSAGEMTELEFONE}" />
                    <p:message for="telefone"/>
                    <br/>


                    <h:outputText value="#{mens.CELULAR}" />
                    <p:inputMask id="celular"  mask="(99)9999-9999"   value="#{manterClienteBean.cliente.celular}" size="30" title="#{mens.MENSAGEMCELULAR}" />
                    <p:message for="celular"/>
                    <br/>




                 <!--   <h:outputText value="#{mens.ENDERECO}" />
                    <p:inputText id="endereco"  value="#{manterClienteBean.cliente.endereco}" size="30" title="#{mens.MENSAGEMENDERECO}" />
                    <p:message for="endereco"/>
                    <br/>-->


                    <h:commandButton value="#{mens.INSERIR}" action="#{manterClienteBean.create}" />
                    <h:commandButton value="#{mens.ALTERAR}" action="#{manterClienteBean.edit}" disabled="#{manterClienteBean.naoSelecionouCliente}"/>
                    <h:commandButton value="#{mens.EXCLUIR}" action="#{manterClienteBean.destroy}" disabled="#{manterClienteBean.naoSelecionouCliente}"/>
                </h:form>

                <br/>
                <h:form>
                    <h:commandButton value="#{mens.PESQUISAR}" action="#{manterClienteBean.findClienteEntities}"/>
                    <p:dataTable style="width:620px "  paginator="true" rows="4" paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5" emptyMessage="#{mens.TABELA_VAZIA}" value="#{manterClienteBean.clientes}" var="p" rendered="#{manterClienteBean.exibeTabela}">
                        <p:column>
                            
                            

                            <h:commandLink value="#{p.nome}" action="paginaManterCliente.xhtml">
                                <f:setPropertyActionListener value="#{p.nome}" target="#{manterClienteBean.cliente.nome}"/>
                                <f:setPropertyActionListener value="#{p.cpfcnpj}" target="#{manterClienteBean.cliente.cpfcnpj}"/>
                                <f:setPropertyActionListener value="#{p.telefone}" target="#{manterClienteBean.cliente.telefone}"/>
                                <f:setPropertyActionListener value="#{p.celular}" target="#{manterClienteBean.cliente.celular}"/>
                                <f:setPropertyActionListener value="#{p.endereco}" target="#{manterClienteBean.cliente.endereco}"/>


                                <f:setPropertyActionListener value="#{p.codigo}" target="#{manterClienteBean.cliente.codigo}"/>
                                <f:setPropertyActionListener value="false" target="#{manterClienteBean.naoSelecionouCliente}"/>
                            </h:commandLink>


                        </p:column>

                        <p:column>
                            <f:facet name="header">#{mens.NOME}</f:facet>
                            <h:outputText value="#{p.nome}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">#{mens.CPFCNPJ}</f:facet>
                            <h:outputText value="#{p.cpfcnpj}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">#{mens.TELEFONE}</f:facet>
                            <h:outputText value="#{p.telefone}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">#{mens.CELULAR}</f:facet>
                            <h:outputText value="#{p.celular}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">#{mens.ENDERECO}</f:facet>
                            <h:outputText value="#{p.endereco}"/>
                        </p:column>






                    </p:dataTable>
                </h:form>

            </ui:define>
        </ui:composition>
    </h:body>
</html>
